home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_WIN.PRG < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.9 KB  |  101 lines

  1. //*****************************************************************************
  2. // C_Win.prg
  3. // Simple window class for OBJECT v2.03
  4. // Copyright (c) 1991, JHK, JHK-Software, Piestany
  5. // Compile with: /N/M/W/A
  6. //-----------------------------------------------------------------------------
  7.  
  8. #include "Object.ch"
  9.  
  10. create class Win from Box     //Usage sequence: Init,Paint,  Hide,Show,... Done
  11.   export:
  12.   var Screen   //""
  13.   var Visible  //false
  14.   method New=WinNew      //o:New()
  15.   method Paint=WinPaint  //o:Paint(IsTop,lDouble)  //overwrite: save_background & set_visibility
  16.   method Show=WinShow    //o:Show()                //you prefer this method
  17.   method Hide=WinHide    //o:Hide()                //...
  18.   method Done=WinDone    //o:Done()                //overwrite: hide_window & box_done
  19.   endclass
  20.  
  21.  
  22. //*****************************************************************************
  23. // Win:New() --> self
  24. // default values for this object
  25. //
  26. constructor WinNew()
  27.   ::Screen:=""
  28.   ::Visible:=false
  29.   return(self)
  30.  
  31.  
  32. //*****************************************************************************
  33. // Win:Paint(IsTop,lDouble) --> true
  34. // physically write simple window into screen.
  35. //
  36. method function WinPaint(IsTop,lDouble)
  37.   local R:=::Row
  38.   local C:=::Col
  39.   local R2:=R+::RowSize+1
  40.   local C2:=C+::ColSize+1
  41.   if ::Shadow; R2++; C2++; endif
  42.   ::Screen:=SaveScreen(R,C,R2,C2)    //save background
  43.   ::super(Box):Paint(IsTop,lDouble)
  44.   ::Visible:=true
  45.   return(true)
  46.  
  47.  
  48. //*****************************************************************************
  49. // Win:Show() --> true
  50. // show previously hided simple window.
  51. //
  52. method function WinShow()
  53.   local R,C,R2,C2,Scr
  54.   if !::Visible
  55.     R:=::Row
  56.     C:=::Col
  57.     R2:=R+::RowSize+1
  58.     C2:=C+::ColSize+1
  59.     Scr:=::Screen
  60.     if ::Shadow; R2++; C2++; endif
  61.     ::Screen:=SaveScreen(R,C,R2,C2)     //save background
  62.     if ::Shadow; R2--; C2--; endif
  63.     RestScreen(R,C,R2,C2,Scr)             //show box
  64.     if ::Shadow; BoxShadow(R,C,R2,C2,ListAsArray(::Color)[nShadow]); endif
  65.     ::Visible:=true
  66.   endif
  67.   return(true)
  68.  
  69.  
  70. //*****************************************************************************
  71. // Win:Hide() --> true
  72. // hide the simple window.
  73. //
  74. method function WinHide()
  75.   local R,C,R2,C2,Scr
  76.   if ::Visible
  77.     R:=::Row
  78.     C:=::Col
  79.     R2:=R+::RowSize+1
  80.     C2:=C+::ColSize+1
  81.     Scr:=::Screen
  82.     ::Screen:=SaveScreen(R,C,R2,C2)    //save the box
  83.     if ::Shadow; R2++; C2++; endif
  84.     RestScreen(R,C,R2,C2,Scr)            //restore background
  85.     ::Visible:=false
  86.   endif
  87.   return(true)
  88.  
  89.  
  90. //*****************************************************************************
  91. // Win:Done() --> true
  92. // destroy simple window.
  93. //
  94. method function WinDone()
  95.   ::Hide()
  96.   ::super(Box):Done()
  97.   return(true)
  98.  
  99. //------------------------------------------------------- eof (c)JHK ----------
  100.  
  101.